#include "ledmessage.h"
#include "ProtocalIdentifier.h"
#include "NetworkCommonFunction.h"

LEDMessage::LEDMessage(const QString &message, int direction):
		SenderCommand(GetProtocalIdentifier("LEDMessage")),
		m_Message(message),
		m_Direction(direction)
{

}

void LEDMessage::constructCommandData(QByteArray &commandData)
{
	unsigned long commandCode = m_CommandType;
	unsigned long commandLength;

	QByteArray messageUtf8 = m_Message.toUtf8();
	commandLength = sizeof(m_Direction) + messageUtf8.size();

	commandData.append(FBtoNetworkCharP(commandCode),4);
	commandData.append(FBtoNetworkCharP(commandLength),4);
	commandData.append(FBtoNetworkCharP(m_Direction), sizeof(m_Direction));
	commandData.append(messageUtf8);

}
